//
// Created by mi on 2024/2/9.
//

#include <iostream>
#include <nlohmann/json.hpp>
using namespace std;
using namespace  nlohmann;
int main() {
    // create an empty structure (null)
    json j;
    j["pi"] = 3.141;
    j["happy"] = true;
    j["name"] = "Niels";
    j["nothing"] = nullptr;
    j["answer"]["everything"] = 42;
    j["list"] = { 1, 0, 2 };
    j["object"] = { {"currency", "USD"}, {"value", 42.99} };
    std::string  input = to_string(j);
    std::cout << to_string(j) << std::endl;
    auto out = json::parse(input.c_str());
    std::string happy = out.at("name");
    std::cout << "happy:" << happy << std::endl;
    return 0;
}


